package com.gg.fruit.controlller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;

import com.gg.entity.Fruit;
import com.gg.fruit.service.FruitService;

import helpers.baseservlet.BaseServlet;

@WebServlet("/fruit/SearchFruitServlet")
public class SearchFruitServlet extends BaseServlet {
	@Autowired
	private FruitService fruitService;

	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String searchname = request.getParameter("searchname");
		List<Fruit> fruits = fruitService.searchFruitByLikeName(searchname);
		request.getSession().setAttribute("searchfruits", fruits);
		response.sendRedirect("/fruits/sel.jsp");
	}

}
